package com.grm.common.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

@Slf4j
public class ListBeanUtils {
    public static <S, T> List<T> copyListProperties(List<S> sourceList, Supplier<T> targetSupplier) {
        List<T> targetList = new ArrayList<>();
        // 使用BeanUtils拷贝List属性
        for (S source : sourceList) {
            T target = targetSupplier.get();
            BeanUtils.copyProperties(source, target);
            targetList.add(target);
        }
        return targetList;
    }
}
